package com.aaa.order.dao;/**
 * Created by Windows10 on 2020/1/7
 */

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * @FileName: OrderItemDao
 * @Description:
 * @Author: Lk
 * @CreateTime: 2020/1/7 16:40
 * @Version: 1.0.0
 */
public interface OrderItemDao {
   /**
   * 订单中商品列表查询
   * @Param
   * @return
   **/
   @Select({"<script>" +
           "select omsi.order_sn,omsi.product_name , omsi.product_quantity " +
           "from oms_order oms  join  oms_order_item omsi " +
           "on oms.id = omsi.order_id" +
           "<where> oms.id= #{id} </where>" +
           "</script>"})
    List<Map> getListByParam(Map map);

    /**
    * 添加商品
    * @Param
    * @return
    **/
    @Insert("insert into oms_order_item(order_id,order_sn,product_name,product_quantity)" +
            "VALUES(#{orderId},#{orderSn},#{productName},#{productQuantity})")
    int add(Map map);

    /**
    * 更新商品内容
    * @Param
    * @return
    **/
    @Update({"<script>" +
            "update oms_order_item " +
            "set order_id=#{orderId}," +
            "order_sn=#{orderSn}," +
            "product_name=#{productName}," +
            "product_quantity=#{productQuantity} " +
            "where id=#{id}"+
            "</script>"})
    int update(Map map);

    /**
    * 删除商品
    * @Param
    * @return
    **/
    @Delete({"<script>" +
            "delete from oms_order_item where id=#{id}" +
            "</script>"})
    int delete(Map map);
}
